#include "SkyDomeFX.h"

SkyDomeFX::SkyDomeFX(ID3D11Device* device)
	: AbstractFX(device, L"FX/SkyDome.fxo") 
{
	//Good idea to init pointers. 
	worldViewProj = NULL;
	cubeMapVar = NULL;

	//Call init functions
	InitInputLayout(device);
	InitShaderVariablePointers();
}

SkyDomeFX::~SkyDomeFX()
{}

void SkyDomeFX::InitInputLayout(ID3D11Device* device)
{
	//Fillout input layout description.
	const D3D11_INPUT_ELEMENT_DESC Pos[] = 
	{
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
	};

	//Create our input layout 	
	CreateInputLayout(device, Pos, 1);
}

void SkyDomeFX::InitShaderVariablePointers()
{
	worldViewProj = effect->GetVariableByName("gWorldViewProj")->AsMatrix();
	cubeMapVar = effect->GetVariableByName("gCubeMap")->AsShaderResource();
}

void SkyDomeFX::SetCbufferPerObjectData(CXMMATRIX worldViewProjectionMatrix)
{
	worldViewProj->SetMatrix((float*) &worldViewProjectionMatrix);
}

void SkyDomeFX::SetCubeMap(ID3D11ShaderResourceView* cubeMap)
{
	cubeMapVar->SetResource(cubeMap);
}